
#include "novice_guide1.h"
#include "first_title.h"

static void ui_guide1_switch_next_callback(lv_event_t* event)
{
    switch(event->code){
    case LV_EVENT_CLICKED:
    {
        debug_d("clicked\n");

        page_install("guide2",lv_page_novice_guide2_create(),NULL);
        page_push_anim("guide2",LOAD_ANIM_MOVE_LEFT);

        break;
    }
    default:break;
    }

    return ;
}

static void ui_guide1_skip_callback(lv_event_t* event)
{
    switch(event->code){
    case LV_EVENT_CLICKED:
    {
        debug_d("clicked\n");

        first_title_hide();
        com_title_create();
        root_page_enter_home(LOAD_ANIM_MOVE_LEFT);
        //pt_flag_new_hand_set(0);
        break;
    }
    default:break;
    }

    return ;
}



void ui_init_novice_guide1_page_src(lv_obj_t *superview)
{
    
    first_title_set( FIRST_PAGE_GUIDE, 1, 0);

    //******************************************************************
    lv_coord_t pw = 0;
    lv_coord_t ph = 0;
    //******************************************************************
    pw = lv_disp_get_hor_res(NULL);
    ph = lv_disp_get_ver_res(NULL);
    //******************************************************************
    lv_obj_t *bg  = lv_obj_create(superview);

    lv_obj_set_style_radius(bg, 0, LV_PART_MAIN);
	lv_obj_set_style_border_width(bg, 0, LV_PART_MAIN);
    lv_obj_set_style_border_opa(bg, LV_OPA_0, LV_PART_MAIN);
	lv_obj_set_style_border_color(bg, lv_color_make(0x00, 0x00, 0x00), LV_PART_MAIN);
    lv_obj_set_style_pad_all(bg,0,0);
    lv_obj_set_scrollbar_mode(bg, LV_SCROLLBAR_MODE_OFF);

    #if 0
	lv_obj_set_style_bg_opa(bg, LV_OPA_0, LV_PART_MAIN);
    #else
	lv_obj_set_style_bg_opa(bg, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(bg, lv_color_make(0,0,0), LV_PART_MAIN);
    #endif

	lv_obj_set_pos(bg,0,0);
	lv_obj_set_size(bg,pw,ph);

    lv_obj_add_event_cb(bg,ui_guide1_switch_next_callback,LV_EVENT_ALL,NULL);
    //**************************************************** */
    //触摸范围
    lv_obj_t *btn_gb = lv_obj_create(superview);
    lv_obj_remove_style_all(btn_gb);
    lv_obj_set_pos(btn_gb,370,12);
	lv_obj_set_size(btn_gb,85,60);
    lv_obj_add_event_cb(btn_gb,ui_guide1_skip_callback,LV_EVENT_ALL,NULL);

    lv_obj_t *btn = lv_obj_create(btn_gb);

	lv_obj_set_style_radius(btn, 15, LV_PART_MAIN);
	lv_obj_set_style_border_width(btn, 1, LV_PART_MAIN);
	lv_obj_set_style_border_color(btn, lv_color_make(0x26,0x7a,0xff), LV_PART_MAIN);
	lv_obj_set_style_border_opa(btn, LV_OPA_100, LV_PART_MAIN);

	lv_obj_set_style_outline_width(btn, 0, LV_PART_MAIN);
	lv_obj_set_style_shadow_width(btn, 0, LV_PART_MAIN);
	lv_obj_set_scrollbar_mode(btn, LV_SCROLLBAR_MODE_OFF);
	lv_obj_set_style_pad_all(btn, 0,0);

    #if 1
	lv_obj_set_style_bg_opa(btn, LV_OPA_0, LV_PART_MAIN);
    #else
	lv_obj_set_style_bg_opa(btn, LV_OPA_100, LV_PART_MAIN);
	lv_obj_set_style_bg_color(btn, lv_color_make(0xff,0,0), LV_PART_MAIN);
    #endif

	lv_obj_set_pos(btn,14,0);
	lv_obj_set_size(btn,65,34);

    lv_obj_add_event_cb(btn,ui_guide1_skip_callback,LV_EVENT_ALL,NULL);
    //**************************************************** */
    lv_obj_t *btn_labe = lv_label_create(btn);
    lv_obj_set_style_text_align(btn_labe,LV_TEXT_ALIGN_CENTER,0);
    lv_obj_set_style_text_font( btn_labe, lv_font_get(20), LV_STATE_DEFAULT );
    lv_obj_set_style_text_opa(btn_labe,LV_OPA_90,LV_PART_MAIN);
    lv_obj_set_style_text_color(btn_labe,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN); 
    lv_label_set_text(btn_labe,"跳过");

    lv_obj_set_pos(btn_labe,0,4);
	lv_obj_set_size(btn_labe,65,28);
    //**************************************************** */
    lv_obj_t * img = lv_img_create(superview);
    lv_img_set_src( img, pt_fs_get("NoviceGuide1.png"));
    lv_obj_align( img,LV_ALIGN_TOP_LEFT,76,48);
    //**************************************************** */

    lv_obj_t * label = lv_label_create(superview);
    lv_obj_set_style_text_font( label, lv_font_get(20), LV_STATE_DEFAULT );
    lv_obj_set_style_text_color(label,lv_color_make(0xff,0xff,0xff),LV_PART_MAIN);
    lv_obj_set_style_text_opa(label,LV_OPA_80,0);
    lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER,0);
    lv_label_set_text( label, "左右滑动可切换智能设备和场景页面\n向下滑动查看更多信息");
    lv_obj_align( label, LV_ALIGN_BOTTOM_MID,0,-20);
    //**************************************************** */
}

static void novice_guide1_page_on_custom_attr_config(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_load(page_base_t* self)
{
    ui_init_novice_guide1_page_src(self->root);
    return ;
}
static void novice_guide1_page_on_view_did_load(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_will_appear(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_did_appear(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_will_disappear(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_did_disappear(page_base_t* self)
{
    return ;
}
static void novice_guide1_page_on_view_did_unload(page_base_t* self)
{
    return ;
}

static page_vtable_t page_param = {
    .on_custom_attr_config  = novice_guide1_page_on_custom_attr_config,
    .on_view_load           = novice_guide1_page_on_view_load,
    .on_view_did_load       = novice_guide1_page_on_view_did_load,
    .on_view_will_appear    = novice_guide1_page_on_view_will_appear,
    .on_view_did_appear     = novice_guide1_page_on_view_did_appear,
    .on_view_will_disappear = novice_guide1_page_on_view_will_disappear,
    .on_view_did_disappear  = novice_guide1_page_on_view_did_disappear,
    .on_view_did_unload     = novice_guide1_page_on_view_did_unload,
};


page_vtable_t* lv_page_novice_guide1_create(void)
{
    return &page_param;
}
